using System;
using System.Collections.Generic;
using shuju_jiange.Com;

namespace shuju_jiange
{
    /// <summary>
    /// 测试新增功能的类
    /// </summary>
    public class TestNewFeatures
    {
        public static void TestDataCountAndColumnX2()
        {
            // 创建测试数据列表
            DataList testList = new DataList();
            
            // 添加测试数据
            Data data1 = new Data();
            data1.SrcData = "123";
            data1.Time = 5; // 设置出现次数为5
            data1.NewDataIntervalY = 10.5f;
            data1.NewEndDiffX = 5.2f;
            data1.TheoreticalInterval = 8.0f;
            data1.OwerList = testList;
            testList.Add(data1);
            
            Data data2 = new Data();
            data2.SrcData = "456";
            data2.Time = 5; // 相同的出现次数，测试计数功能
            data2.NewDataIntervalY = 12.0f;
            data2.NewEndDiffX = 6.0f;
            data2.TheoreticalInterval = 9.0f;
            data2.OwerList = testList;
            testList.Add(data2);
            
            Data data3 = new Data();
            data3.SrcData = "789";
            data3.Time = 3; // 不同的出现次数
            data3.NewDataIntervalY = 8.0f;
            data3.NewEndDiffX = 4.0f;
            data3.TheoreticalInterval = 7.5f;
            data3.OwerList = testList;
            testList.Add(data3);
            
            // 设置手动输入百分比
            Data.ManualInputPercent = 0.1f; // 10%
            
            // 测试数据出现次数
            Console.WriteLine("=== 测试数据出现次数 ===");
            Console.WriteLine($"数据123(Time=5)的DataCount: {data1.DataCount}"); // 应该是2，因为data1和data2的Time都是5
            Console.WriteLine($"数据456(Time=5)的DataCount: {data2.DataCount}"); // 应该是2，因为data1和data2的Time都是5
            Console.WriteLine($"数据789(Time=3)的DataCount: {data3.DataCount}"); // 应该是1，因为只有data3的Time是3
            
            // 测试列X2计算
            Console.WriteLine("\n=== 测试列X2计算 ===");
            Console.WriteLine($"数据123的列X2值: {data1.ColumnX2}");
            Console.WriteLine($"数据456的列X2值: {data3.ColumnX2}");
            
            // 详细计算过程
            Console.WriteLine("\n=== 详细计算过程 (数据123) ===");
            float part1 = data1.NewDataIntervalY * data1.DataCount;
            float part2 = data1.NewDataIntervalY + data1.NewEndDiffX;
            float part3 = data1.TheoreticalInterval * Data.ManualInputPercent;
            Console.WriteLine($"Y值*次数: {data1.NewDataIntervalY} * {data1.DataCount} = {part1}");
            Console.WriteLine($"Y+X: {data1.NewDataIntervalY} + {data1.NewEndDiffX} = {part2}");
            Console.WriteLine($"理论间隔*手动百分比: {data1.TheoreticalInterval} * {Data.ManualInputPercent} = {part3}");
            Console.WriteLine($"列X2总计: {part1} + {part2} + {part3} = {data1.ColumnX2}");
        }
    }
}